﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Admin.Master" AutoEventWireup="true" Inherits="System.Web.Mvc.ViewPage" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContentPlaceHolder" runat="server">
<script type="text/javascript" src="../../../../Content/jquery-1.2.6.js"></script>
<script type="text/javascript" src="../../../../Content/jquery.functions.js"></script>
<script type="text/javascript">
    $(document).ready(function(){
   // Your code here
        $.getJSON("/Json/Posts", null, function(data) {
            var text='<ul>';
            $.each(data, function(index, optionData) {
                var created = dateparse( optionData.Created  )
                text = text + "<li>" + '<div class="title"><a href="' + optionData.Url +'">' + optionData.Title + "</a> " 
                
                + '<div class="dateposted">' + created.toLocaleString() + "</div>"
                + "</div>" + '<div class="body">' + optionData.Body.substring(0,300) +  "</div>" +
                '<div class="edit"><a href="' + optionData.EditUrl + '">Edit</a>' +
                '<a class="delete" href="' + optionData.DeleteUrl + '">Delete</a></div>' +
                '<div class="clear"/>' +
                  "</li>";
            });

            text = text + "</ul>";
            $('#posts').html(
                text
            );        
        });
    });
    
    $(function() {
         $('#monthList').change(function() {
            $.getJSON("/Json/Posts/" + this.value, null, function(data) {
                var text='<ul>';
                $.each(data, function(index, optionData) {
                    var created = dateparse( optionData.Created  )
                    text = text + "<li>" + '<div class="title"><a href="' + optionData.Url +'">' + optionData.Title + "</a> " 
                    
                    + '<div class="dateposted">' + created.toLocaleString() + "</div>"
                    + "</div>" + '<div class="body">' + optionData.Body.substring(0,300) +  "</div>" +
                    '<div class="edit"><a href="' + optionData.EditUrl + '">Edit</a>' +
                    '<a class="delete" href="' + optionData.DeleteUrl + '">Delete</a></div>' +
                    '<div class="clear"/>' +
                      "</li>";
                });

                text = text + "</ul>";
                $('#posts').html(
                    text
                );        
            });
         });
    });
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContentPlaceHolder" runat="server">
 <p>
 <strong>Month Filter</strong> <%= Html.DropDownList("All Months", "monthList") %>
 </p>

<div id="posts">
</div>



</asp:Content>
